<template>
  <div class="users">
    <div class="toolbar">
      <el-button type="primary" @click="handleAdd">
        <el-icon><Plus /></el-icon>
        添加用户
      </el-button>
    </div>
    
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="ID" width="80" />
      <el-table-column prop="username" label="用户名" />
      <el-table-column prop="email" label="邮箱" />
      <el-table-column label="操作" width="180">
        <template #default="scope">
          <el-button type="primary" link @click="handleEdit(scope.row)">
            编辑
          </el-button>
          <el-button type="danger" link @click="handleDelete(scope.row)">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { ref } from 'vue'

export default {
  name: 'Users',
  setup() {
    const tableData = ref([
      {
        id: 1,
        username: 'admin',
        email: 'admin@example.com'
      }
    ])

    const handleAdd = () => {
      console.log('添��用户')
    }

    const handleEdit = (row) => {
      console.log('编辑用户', row)
    }

    const handleDelete = (row) => {
      console.log('删除用户', row)
    }

    return {
      tableData,
      handleAdd,
      handleEdit,
      handleDelete
    }
  }
}
</script>

<style scoped>
.toolbar {
  margin-bottom: 16px;
}
</style> 